import psycopg2

pgConnection = psycopg2.connect(database="metadata", user="metadata", password="metadata123", host="192.168.1.132",
                                port="5632")

pgCommand = pgConnection.cursor()

try:
    map_info_list = open('C:\\Users\\h295061\\metadata_public_base_map_information.csv', 'rb')

    for map_info in map_info_list.read():
        pgCommand.execute(
            "insert into base_map_information (section_id, map_name, map_source, map_bind_json, create_time) values (%s)"
            , str(map_info))

except IOError:
    print('*** file open error:')

finally:
    pgConnection.commit()
    pgConnection.close()

print("done successfully")
